package cn.jetpiece.cloud.joss.api.object;

import cn.jetpiece.cloud.joss.api.object.model.params.CreateBucketParam;
import cn.jetpiece.cloud.joss.api.object.model.params.UpdateBucketParam;
import cn.jetpiece.cloud.joss.api.object.model.query.BucketQuery;
import cn.jetpiece.cloud.joss.api.object.model.result.BucketResult;
import cn.jetpiece.cloud.model.page.PageResult;
import cn.jetpiece.cloud.model.response.Result;
import cn.jetpiece.cloud.resource.annotation.annotation.ApiResource;
import cn.jetpiece.cloud.resource.annotation.annotation.ScanResource;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMethod;
import springfox.documentation.annotations.ApiIgnore;

import javax.validation.Valid;


/**
 * 桶接口
 *
 * @author XuJZ
 * @since 2020-09-05 15:41:52
 */
@Api(tags = "桶")
@ApiResource(name = "桶")
public interface BucketApi {

    String API = "/oss/buckets";

    /**
     * 新增桶
     *
     * @param param 新增参数
     * @return 返回结果
     */
    @ApiOperation(value = "新增桶")
    @ScanResource(name = "新增桶", path = API, method = RequestMethod.POST)
    Result<String> add(@RequestBody @Valid CreateBucketParam param);

    /**
     * 修改桶
     *
     * @param param 修改参数
     * @return 返回结果
     */
    @ApiIgnore
    @ApiOperation(value = "修改桶")
    @ScanResource(name = "修改桶", path = API, method = RequestMethod.PUT)
    Result<String> update(@RequestBody @Valid UpdateBucketParam param);

    /**
     * 删除桶
     *
     * @param id 主键
     * @return 返回结果
     */
    @ApiOperation(value = "删除桶")
    @ScanResource(name = "删除桶", path = API + "/{id}", method = RequestMethod.DELETE)
    Result<String> delete(@PathVariable(name = "id") String id);

    /**
     * 查询桶信息
     *
     * @param id 主键
     * @return 返回结果
     */
    @ApiOperation(value = "查询桶信息")
    @ScanResource(name = "查询桶信息", path = API + "/{id}", method = RequestMethod.GET)
    Result<BucketResult> get(@PathVariable(name = "id") String id);

    /**
     * 分页获取桶
     *
     * @param query 查询条件
     * @return 返回结果
     */
    @ApiOperation(value = "分页获取桶")
    @ScanResource(name = "分页获取桶", path = API, method = RequestMethod.GET)
    Result<PageResult<BucketResult>> page(BucketQuery query);

}
